1. Field of the Invention
The invention relates to memories, and more particularly to flash memories.
2. Description of the Related Art
A flash memory comprises a plurality of blocks for data storage. A frequency for erasing or programming a block is referred to as an erase count or a write count of the block. A controller of a flash memory records the erase counts of all blocks of the flash memory in an erase count table. A frequency for reading a block is referred to as a read count of the block. When a block is used with a high frequency, the erase count and the read count of the block is also high.
When a block stores data with a high used frequency, the block has a high erase count and a high read count and is easily damaged. New data cannot be written to a damaged block. In addition, if data has been stored in a damaged block, when the data is read out from the damaged block, the read-out data has a high bit error rate. Referring to FIG. 2A, a schematic diagram of a relationship between an erase count and a data error rate of a block is shown. When a block has a high erase count, the block also has a high data error rate. Referring to FIG. 2B, a schematic diagram of a relationship between a read count and a data error rate of a block is shown. When a block has a high read count, the block also has a high data error rate. Referring to FIG. 2C, a schematic diagram of a relationship between an erase count and a data retention period of a block is shown. A block with a high erase count has a short data retention period, and a block with a low erase count has a long data retention period.
To prevent a block with a high erase count from damage, a controller of a flash memory performs a wear-leveling process to equally use all blocks of the flash memory. Referring to FIG. 1, a schematic diagram of a distribution of erase counts of all blocks of a flash memory is shown. The blocks of the flash memory have different physical block addresses. After a wear-leveling process is performed, the blocks with different physical block addresses have the same erase counts. Thus, the situation where a single block has a high erase count and is easily damaged is avoided.
The importance of data stored in the flash memory, however, is different. For example, system data such as a partition table and a root directory has a high importance. When a controller performs a wear-leveling process, data with high importance may be written to a block with a high erase count. If the data with high importance is damaged due to the high erase count of the block, errors may occur in the operation of the system. For example, when a partition table is detected, all data stored in the flash memory cannot be read from the flash memory according to the partition table. When a root directory is defective, the data stored in the directory with errors also cannot be read out. Thus, a data writing method for a flash memory is required to prevent the aforementioned defects.